package com.dave.dubbo.nacos.consumer.controller;

import com.dave.dubbo.provider.api.EmailService_2_7_8;
import com.dave.dubbo.provider.api.MessageService_2_7_8;
import com.dave.dubbo.provider.api.entity.UserTest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wangwj
 * @version 1.0
 * @date 2021/12/16
 * @description: TODO
 */

@RestController
@RequestMapping("/api/message")
public class MessageController {

    @DubboReference(version = "1.0.0")
    private MessageService_2_7_8 messageService_2_7_8;
    @DubboReference(version = "1.0.0")
    private EmailService_2_7_8 emailService_2_7_8;

    @RequestMapping("/sayHello")
    public String sayHello(String text) {
        return messageService_2_7_8.sayHello(text);
    }

    @RequestMapping("/sayHello1")
    public String sayHello1(String text) {
        UserTest userTest = new UserTest();
        userTest.setId("1");
        userTest.setName(text);
        return messageService_2_7_8.sayHelloUser(userTest);
    }

    @RequestMapping("/sendEmail")
    public String sendEmail(String title) {
        return emailService_2_7_8.sendEmail(title);
    }
}
